package ch.bfh.fbi.mobicomp.zap04;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

public class Zap04MessageBroadcastReceiver extends BroadcastReceiver {
	private static final String TAG = "Zap04MessageBroadcastReceiver";
	private static final String destructionKey = "destroyMe";
	private static final String haltKey = "stopDestroyMe";

	
	@Override
	public void onReceive(Context context, Intent intent) {
		Intent zapperIntent = new Intent(
				"ch.bfh.fbi.mobicomp.zap04.ZAP_04_SERVICE");
		if (intent.getExtras().getBoolean(destructionKey)) {
			Log.d(TAG, "destruction initiated...");
			zapperIntent.putExtra("start",true);
			
		}else if(intent.getExtras().getBoolean(haltKey)) {
			Log.d(TAG, "destruction aborted...");
			zapperIntent.putExtra("stop",true);
		}	
		
		context.startService(zapperIntent);		
	}

}
